﻿<?php
	$this->headMeta()->appendHttpEquiv('Content-Type', 'text/html;charset=utf-8');
	$this->headTitle()->setSeparator(' - ');
	$this->headTitle('Phòng trọ');
	
	echo $this->doctype();
?>  
<html lang="en" xml:lang="en" xmlns="http://www.w3.org/1999/xhtml">
	<?php echo $this->render('layouts/front.phtml'); ?>
	<body <?php echo $this->bodyScripts ?>>
		<div id="preLoadImages"></div>
		<div id="wrapper">
			<?php echo $this->render('layouts/header.phtml'); ?>
			<?php echo $this->render('layouts/menu.phtml'); ?>
		    <?php echo $this->layout()->content ?>
		    <?php echo $this->render('layouts/footer.phtml'); ?>
	    </div>
	</body>
</html>

<script type="text/javascript">
	var clicked = false;
	var left_pos = ($(window).width() - 200) / 2;
	
	function clickAdv(isLogin, user_id, page_id, position_id, url, point) {
		if (isLogin) {
			if (!clicked) {
				clicked = true;
				
				$.ajax({
				    type: 'POST',
				    url: '/ajax/clickadv',
				    async: true,
				    dataType: "json",
				    data: { user: user_id, page: page_id, position: position_id, user_point: point},
				    success: function(data) {
				    	if(data.result) {
				    		bootbox.alert("Bạn được cộng " + point + " điểm.", function() {
					    		if (url != "") {
									window.open(url, '_blank');
								}
						    });
				    	} else {
				    		bootbox.alert("Xử lý thất bại.", function() { });
				    	}
				    	
				    	$('.bootbox').attr('style', 'overflow: hidden; width: 200px; left: 0; margin-left: ' + left_pos + 'px; top: 0; margin-top: 250px; font-size: 14px');
				    	clicked = false;
				    },
				    error: function(data) {
				    	bootbox.alert("Xử lý thất bại.", function() { });
				    	$('.bootbox').attr('style', 'overflow: hidden; width: 200px; left: 0; margin-left: ' + left_pos + 'px; top: 0; margin-top: 250px; font-size: 14px');
				    	clicked = false;
				    }
				});
			}
		} else {
			if (url != "") {
				window.open(url, '_blank');
			}
			
			$('.bootbox').attr('style', 'overflow: hidden; width: 200px; left: 0; margin-left: ' + left_pos + 'px; top: 0; margin-top: 250px; font-size: 14px');
		}

		return false;
	}
</script>